package com.uni.service.impl;

import com.uni.dao.PermMapper;
import com.uni.dao.RolePermsMapper;
import com.uni.pojo.*;
import com.uni.service.PermService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import java.util.List;

/**
 * Author:      Unirithe/Mr.Chao
 * CSDN:        https://blog.csdn.net/Unirithe
 * CreatedTime:  2022/2/11 15:09
 **/
@Controller
public class PermServiceImpl implements PermService {

    @Autowired
    PermMapper permMapper;
    @Autowired
    RolePermsMapper rolePermsMapper;
    @Override
    public List<Perm> queryPermByRole(Role role) {
        return permMapper.selectByRole(role);
    }

    @Override
    public List<Perm> queryAllPerm() {
        return permMapper.selectByExample(new PermExample());
    }

    @Override
    public Perm queryPermById(Integer id) {
        return permMapper.selectByPrimaryKey(id);
    }

    @Override
    public int modifyById(Perm perm) {
        return permMapper.updateByPrimaryKey(perm);
    }

    @Override
    public int addPerm(Perm perm) {
        return permMapper.insertSelective(perm);
    }

    @Override
    public int deletePerm(Integer id) {
        return permMapper.deleteByPrimaryKey(id);
    }


}
